/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package cn.edu.just.secondwebapp.test;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author JUST
 */
public class JSONDemo {
    public static void main(String[] args){
        Map<String,Object> student = new HashMap<>();
        student.put("学号", "220292930120");
        student.put("姓名", "张三");
        student.put("成绩", 100.0);
        student.put("生日", new Date());
        Gson gson = new GsonBuilder().setDateFormat("yyyy年MM月dd日").create();
        String s = gson.toJson(student);
        Map s2 = gson.fromJson(s, Map.class);
        System.out.println(s);
        System.out.println(s2);
    }
}
